home *** CD-ROM | disk | FTP | other *** search
Text File | 2000-03-27 | 63.3 KB | 2,291 lines |
- property pCharCode, pLastDrinkResponse, pLastDrinkTaste, pPatronGaveTip, pDownFlag, pPerformanceInfo, pAnimating, pLabels, pActionList, pStepsInCurrentAction, pTurnOffAnim, pDrinksBeenServed, pPatience, pThrottleFrame, pThrottleTime, pPoints, pMaxPoints, pAccuracy, pDifficulty, pDrinkImpatience, pPostDrinkPatience, pPostDrinkSpacing, pPostDrinkStay, pRecipeID, pForcedRecipe, pDrinkOrder, pLastDrinkType, pCharmedPoints, pOrigRect, pOrigReg, pBigFlashRect, pRecipeName, pRecipeText, pRecipeQuick, pSoundChannel, pMyBarSlot, pWaitForVO, pLastTiming, pMouthTiming, pMouthTimingCount, pStatus, pWaitToOrderStatus, pWaitForDrinkStatus, pMouthList, pTimeApproached, pTimeOrdered, pTimeServed, pTimeLastAction, pSpr, pMouthSpr, pHandSpr, pGlassSpr, ancestor, pNoEventsDuringTest, pOrderBeckon, pOrderAntic, pOrderImpatient, pOrderLeave, pServeAntic, pServeImpatient, pServeLeave, pFrameToRecreate, pSourMilk, pLiquorGlass, pLiquorRecipe, pJuiceGlass, pPatronName
- global gBarTopManager, debug, gCharChildren, gRecipeWindow, gSodaDebug, gGameLevel, gMachineSpeed, gBounceInProgress, gArbusSprite, gTipPending, gQuality, gPlayerTips
-
- on setTimeLastAction me
- pTimeLastAction = now()
- end
-
- on timeSinceLastAction me
- return elapsedTime(pTimeLastAction)
- end
-
- on timeSinceApproached me
- return elapsedTime(pTimeApproached)
- end
-
- on timeSinceOrdered me
- return elapsedTime(pTimeOrdered)
- end
-
- on timeSinceServed me
- return elapsedTime(pTimeServed)
- end
-
- on blankRecipeValues
- pRecipeName = "No Drink"
- end
-
- on removeCharacterTraces me
- pCharCode = VOID
- pRecipeID = 0
- pForcedRecipe = 0
- pStatus = #offStage
- blankRecipeValues(me)
- pPatronName = "No Patron"
- clearRecipe(pMyBarSlot)
- pActionList = []
- pStepsInCurrentAction = [:]
- pMouthList = [:]
- pStatus = #offStage
- pLastDrinkResponse = #none
- pLastDrinkTaste = #none
- ancestor = VOID
- end
-
- on endSprite me
- pSpr.rect = pOrigRect
- pSpr.visible = 1
- removeFromActorList(pSpr)
- end
-
- on beginSprite me
- global gRetrievedGame, pThrottleFrame
- pThrottleFrame = 0
- pSpr = sprite(me.spriteNum)
- pSpr.quality = #high
- pMouthSpr = sprite(me.spriteNum + 1)
- pGlassSpr = sprite(me.spriteNum + 2)
- pHandSpr = sprite(me.spriteNum + 3)
- pOrigRect = pSpr.rect
- pOrigReg = pSpr.member.regPoint
- setFlashRectsInk(me)
- pSoundChannel = SpriteToSoundChannel(me.spriteNum)
- pMyBarSlot = SpriteToBarSlot(me.spriteNum)
- removeCharacterTraces(me)
- gotoFlashFrame(pSpr, "APPROACH", 1)
- updateStage()
- setFlashAttributes(me)
- hide(me)
- if pSpr.frame = 1 then
- pSpr.frame = 2
- end if
- pOrderBeckon = currentLevel(#wo1)
- pOrderAntic = currentLevel(#wo2)
- pOrderImpatient = currentLevel(#wo3)
- pOrderLeave = currentLevel(#wo4)
- pServeAntic = currentLevel(#ws1)
- pServeImpatient = currentLevel(#ws2)
- pServeLeave = currentLevel(#ws3)
- end
-
- on setFlashRectsInk me
- global gShowFlashRects
- if gShowFlashRects = 1 then
- pSpr.ink = 0
- else
- pSpr.ink = 36
- end if
- end
-
- on stepFrame me
- global gThrottleRate, gPauseState, gRetrievedGame
- if gPauseState or gRetrievedGame or inMenuMode() then
- exit
- end if
- if pWaitForVO then
- if not soundPlaying(me) then
- pWaitForVO = 0
- end if
- if not voidp(pMouthTiming) then
- if soundPlaying(me) then
- doMouthSync(me)
- else
- pMouthTiming = VOID
- mShowMouth(me, 0)
- pWaitForVO = 0
- doNextAction(me)
- end if
- else
- end if
- exit
- end if
- if pAnimating then
- thisOne = pLabels[pAnimating]
- startFrame = thisOne[#start]
- endFrame = thisOne[#end]
- if (pSpr.frame > endFrame) or (pSpr.frame < startFrame) then
- pSpr.frame = startFrame
- pThrottleTime = now()
- else
- if pSpr.frame < endFrame then
- elapsedSoFar = elapsedTime(pThrottleTime)
- animSpeed = float(elapsedSoFar) / (1 + max(0, pThrottleFrame - startFrame))
- if animSpeed <= gThrottleRate then
- alterQuality(me, #high)
- gMachineSpeed = #fast
- exit
- else
- if animSpeed > (3 * gThrottleRate) then
- alterQuality(me, gQuality)
- gMachineSpeed = #verySlow
- else
- if animSpeed > (2 * gThrottleRate) then
- alterQuality(me, gQuality)
- gMachineSpeed = #slow
- else
- if animSpeed > (1.14999999999999991 * gThrottleRate) then
- gMachineSpeed = #medium
- else
- gMachineSpeed = #medium
- alterQuality(me, #high)
- end if
- end if
- end if
- end if
- pThrottleFrame = pThrottleFrame + 1
- pSpr.frame = pThrottleFrame
- if (pStatus = #bouncing) or inTestMode() then
- gArbusSprite.frame = pThrottleFrame
- end if
- else
- if soundPlaying(me) then
- if pPerformanceInfo = 0 then
- pPerformanceInfo = 1
- showPerformance(me, startFrame, endFrame, "Finished Animation before sound:", thisOne[#label])
- end if
- exit
- else
- if pPerformanceInfo = 0 then
- showPerformance(me, startFrame, endFrame, "Finished Animation:", thisOne[#label])
- else
- showPerformance(me, startFrame, endFrame, "When Sound Finished:", thisOne[#label])
- end if
- pPerformanceInfo = 0
- doNextAction(me)
- end if
- end if
- end if
- end if
- end
-
- on alterQuality me, newQuality
- pSpr.quality = newQuality
- gArbusSprite.quality = newQuality
- end
-
- on showPerformance me, startFrame, endFrame, prompt, labels
- global gThrottleRate
- if not debug then
- exit
- end if
- elapsedSoFar = elapsedTime(pThrottleTime)
- frames = endFrame - startFrame + 1
- achieved = float(elapsedSoFar) / frames
- put prompt && labels && "for #" && pCharCode && "in position" && pMyBarSlot
- rateData = float(elapsedSoFar) / frames && "ticks/frame"
- target = "Target rate was" && gThrottleRate
- if achieved <= (gThrottleRate + 0.14999999999999999) then
- put "FAST Rate of" && rateData && "exceeded!" && target
- else
- if achieved <= (gThrottleRate + 0.5) then
- put "GOOD Rate of" && rateData && "achieved!" && target
- else
- if achieved <= (gThrottleRate * 2) then
- put "SLOW Rate of" && rateData && "is too slow" && target
- else
- put "VERY SLOW Rate of" && rateData && "really dragged." && target
- end if
- end if
- end if
- end
-
- on doMouthSync me
- thisTime = sound(pSoundChannel).currentTime
- startAt = pLastTiming
- repeat with pLastTiming = startAt to pMouthTimingCount
- if thisTime < pMouthTiming[pLastTiming] then
- if (pLastTiming - 1) > 0 then
- sendSprite(pMouthSpr, #mMoveMouth, getPropAt(pMouthTiming, pLastTiming))
- else
- sendSprite(pMouthSpr, #mMoveMouth, "nc1")
- end if
- exit repeat
- end if
- end repeat
- end
-
- on mShowMouth me, flag
- if voidp(flag) then
- if getFrameLabel(pSpr, pSpr.frame) = "TBASE" then
- flag = 1
- else
- flag = 0
- end if
- end if
- sendSprite(pMouthSpr, #mAdjustPosition, getBarPositionOffset(gBarTopManager, pMyBarSlot), flag)
- end
-
- on speak me, speakSound
- if pNoEventsDuringTest then
- exit
- end if
- thisSound = randomFromList(speakSound)
- if debug then
- put "speak" && thisSound
- end if
- playVO(me, thisSound, 0, VOID)
- end
-
- on newRect me, newFlashRect
- global gDontAdjustFlashRect, gShowArbusRects
- if pNoEventsDuringTest then
- exit
- end if
- if gShowArbusRects then
- put "NEWRECT string event:" && newFlashRect
- end if
- newRects = value(newFlashRect)
- if gShowArbusRects then
- put "NEWRECT value:" && newRects
- end if
- if ilk(newRects, #rect) then
- patronRect = newRects
- arbusRect = 1
- else
- patronRect = newRects[1]
- arbusRect = newRects[2]
- end if
- if ilk(patronRect, #rect) then
- adjustFlashRect(me, VOID, patronRect)
- end if
- if ilk(arbusRect, #rect) then
- adjusted = adjustFlashRect(me, VOID, arbusRect, 1)
- newSpriteRect = adjusted[#rect]
- trimLeft = adjusted[#left]
- trimTop = adjusted[#top]
- sendSprite(gArbusSprite, #adjustFlashRect, newSpriteRect, arbusRect, trimLeft, trimTop)
- else
- if not voidp(arbusRect) and (arbusRect = 0) then
- sendSprite(gArbusSprite, #hide)
- end if
- end if
- end
-
- on gotoLoop me, danceLoopEvent
- global gCurrentSong, gThrottleRate
- thisEvent = danceLoopEvent
- the itemDelimiter = ","
- labelName = item 1 of thisEvent
- loopMax = integer(item 2 of thisEvent)
- me.pDanceLoops = me.pDanceLoops + 1
- if me.pDanceLoops <= loopMax then
- if me.pFavoriteSong = gCurrentSong then
- loopFrame = findLabel(pSpr, labelName)
- if (loopFrame > 0) and (loopFrame < pSpr.frame) then
- frameDiff = pSpr.frame - loopFrame
- pThrottleTime = pThrottleTime + (gThrottleRate * frameDiff)
- pThrottleFrame = pThrottleFrame - frameDiff
- else
- exit
- end if
- end if
- end if
- end
-
- on move_glass me, glassPosition
- if glassPosition = "Hide" then
- showHandAndGlass(me, 0)
- else
- glassPosition = char 1 of glassPosition
- showHandAndGlass(me, 1)
- nextGlass = nextGlassMember(me, glassPosition)
- nextHand = nextHandMember(me, glassPosition)
- if the number of member nextGlass < 1 then
- put "Glass" && nextGlass && "is missing"
- else
- pGlassSpr.member = nextGlass
- end if
- if the number of member nextHand < 1 then
- put "Hand" && nextHand && "is missing"
- else
- pHandSpr.member = nextHand
- end if
- end if
- end
-
- on mouseDown
- pDownFlag = 1
- nothing()
- end
-
- on mouseEnter
- pDownFlag = 0
- if not draggingAnything() then
- thisRect = pSpr.rect
- thisLabel = marker(0)
- if (thisLabel <> label("card")) and (thisLabel <> label("sodaGun")) then
- showToolTip(pSpr, pCharCode, point(thisRect.left + (thisRect.width / 2), min(260, thisRect.bottom - 40)), 1)
- end if
- end if
- end
-
- on mouseLeave
- pDownFlag = 0
- if not draggingAnything() then
- hideToolTip()
- end if
- end
-
- on mouseUp me
- if pDownFlag then
- checkIfFlashWasHit(me, pSpr)
- end if
- end
-
- on busy me
- return pActionList <> []
- end
-
- on dance me, inSound
- if voidp(inSound) then
- inSound = "juke_sound"
- end if
- if marker(0) <> label("juke") then
- replaceDraggingAnything()
- storeHelpPointerState()
- waitCursor()
- soundFX(inSound, 0, 0)
- go("juke")
- else
- if marker(0) = label("juke") then
- soundFX(inSound, 0, 0)
- go("juke close")
- end if
- end if
- end
-
- on goBase me
- if statusIs(me, [#retreating, #bouncing, #offStage]) then
- debugAlert("Shouldn't get to goBase with status" && pStatus)
- exit
- end if
- forceNewAnimation(me)
- playAnim(me, #base1, VOID, #stationary)
- end
-
- on mRecreate me, character, patronGaveTip, charmedPoints, drinkOrder, lastDrinkType, lastDrinkResponse, lastDrinkTaste, drinksBeenServed, points, maxPoints, accuracy, status, frameNum, throttleTime, timeApproached, timeOrdered, timeServed, timeLastAction, recipeID, forcedRecipe, waitToOrderStatus, waitForDrinkStatus, animating, actionList, stepsInCurrentAction, turnOffAnim, waitForVO, lastTiming, mouthTiming, mouthTimingCount, inRect, sourMilk, liquorGlass, liquorRecipe, juiceGlass
- global gImplementedCharacters
- pCharCode = character
- if voidp(pCharCode) then
- removeCharacterTraces(me)
- exit
- end if
- ancestor = gCharChildren[pCharCode]
- pPatronName = me.pName
- pPatronGaveTip = patronGaveTip
- pCharmedPoints = charmedPoints
- pDrinkOrder = drinkOrder
- if not voidp(pDrinkOrder) then
- me.pHasEverOrdered = 1
- end if
- pLastDrinkType = lastDrinkType
- pLastDrinkResponse = lastDrinkResponse
- pLastDrinkTaste = lastDrinkTaste
- pDrinksBeenServed = drinksBeenServed
- pPoints = points
- pMaxPoints = maxPoints
- pAccuracy = accuracy
- pSourMilk = sourMilk
- pLiquorGlass = liquorGlass
- pLiquorRecipe = liquorRecipe
- pJuiceGlass = juiceGlass
- pStatus = status
- pThrottleTime = reviseTime(throttleTime)
- pTimeApproached = reviseTime(timeApproached)
- pTimeOrdered = reviseTime(timeOrdered)
- pTimeServed = reviseTime(timeServed)
- pTimeLastAction = reviseTime(timeLastAction)
- getRecipeInfo(me, recipeID, 0)
- pForcedRecipe = forcedRecipe
- pWaitToOrderStatus = waitToOrderStatus
- pWaitForDrinkStatus = waitForDrinkStatus
- pAnimating = animating
- if voidp(actionList) then
- pActionList = []
- else
- pActionList = duplicate(actionList)
- end if
- if voidp(stepsInCurrentAction) then
- pStepsInCurrentAction = [:]
- else
- pStepsInCurrentAction = duplicate(stepsInCurrentAction)
- end if
- pTurnOffAnim = turnOffAnim
- waitForVO = pWaitForVO
- lastTiming = pLastTiming
- mouthTiming = pMouthTiming
- mouthTimingCount = pMouthTimingCount
- calcPostDrinkStuff(me)
- getIntoxication(me)
- pMouthList = getMouthList(pCharCode)
- if voidp(pMouthList) then
- pMouthList = [:]
- end if
- oldMember = pSpr.member
- pSpr.member = me.pFlashCharMember
- updateStage()
- unLoad(oldMember)
- setFlashAttributes(me)
- oldMember = pMouthSpr.member
- pMouthSpr.member = me.pFlashMouthMember
- preLoad(pMouthSpr.member)
- updateStage()
- unLoad(oldMember)
- showMemoryStatus()
- reg = gImplementedCharacters[pCharCode][#regPoint]
- pSpr.member.regPoint = reg
- pBigFlashRect = offset(pOrigRect, pOrigReg.locH - reg.locH, pOrigReg.locV - reg.locV)
- pLabels = setFlashLabels(me, pSpr)
- pFrameToRecreate = frameNum
- end
-
- on calcPostDrinkStuff me
- temp1 = currentLevel(#POSTDRINKMINPATIENCE)
- temp2 = currentLevel(#POSTDRINKMAXPATIENCE)
- pPostDrinkPatience = seconds(randomBetween(temp1, temp2)) * currentPatience(me)
- pPostDrinkSpacing = seconds(currentLevel(#POSTDRINKANTICINTERVAL))
- pPostDrinkStay = currentLevel(#postDrinkStayChance) > random(100)
- end
-
- on setFlashAttributes me
- pSpr.static = 1
- pSpr.originMode = #topLeft
- pSpr.clickMode = #boundingBox
- pSpr.actionsEnabled = 1
- pSpr.buttonsEnabled = 0
- end
-
- on mReposition me
- if voidp(pFrameToRecreate) then
- hide(me)
- exit
- end if
- fixEventTriggers(me)
- gotoFlashFrame(pSpr, pFrameToRecreate, 1)
- if pWaitForVO then
- startAnimating(me, pAnimating)
- nextStepInAnim(me)
- else
- if pAnimating then
- pNoEventsDuringTest = 1
- startAnimating(me, pAnimating)
- nextStepInAnim(me)
- pNoEventsDuringTest = 0
- else
- startFlashAnim(me, "Base1")
- end if
- end if
- end
-
- on approach me, character
- global gImplementedCharacters
- pCharCode = character
- ancestor = gCharChildren[pCharCode]
- me.pDrinkTicket = max(0, me.pDrinkTicket - 1)
- pPatronGaveTip = 0
- if bouncingOrRetreating(me) then
- debugAlert("Should never be approaching while being bounced or retreating")
- exit
- end if
- pCharmedPoints = 0
- blankRecipeValues(me)
- pPatronName = me.pName
- pDrinkOrder = VOID
- pLastDrinkType = VOID
- pDrinksBeenServed = 0
- if inRecipeMode() then
- pRecipeID = pForcedRecipe
- else
- pRecipeID = 0
- end if
- pPoints = 0
- pMaxPoints = 0
- pAccuracy = 0
- pStatus = #approaching
- pTimeApproached = now()
- pWaitToOrderStatus = #new
- pWaitForDrinkStatus = #new
- setTimeLastAction()
- resetRecipe(me)
- pMouthList = getMouthList(pCharCode)
- if voidp(pMouthList) then
- pMouthList = [:]
- end if
- oldMember = pSpr.member
- pSpr.member = me.pFlashCharMember
- updateStage()
- unLoad(oldMember)
- setFlashAttributes(me)
- oldMember = pMouthSpr.member
- pMouthSpr.member = me.pFlashMouthMember
- preLoad(pMouthSpr.member)
- updateStage()
- unLoad(oldMember)
- if not me.pHasEverOrdered then
- preLoad(member(pCharCode & "_id"))
- end if
- showMemoryStatus()
- show(me)
- reg = gImplementedCharacters[pCharCode][#regPoint]
- pSpr.member.regPoint = reg
- pBigFlashRect = offset(pOrigRect, pOrigReg.locH - reg.locH, pOrigReg.locV - reg.locV)
- pLabels = setFlashLabels(me, pSpr)
- incrementNumVisits(me)
- if authoring() then
- jumpToBase = inTestMode()
- else
- jumpToBase = 0
- end if
- if jumpToBase then
- if me.pAlreadyCarded then
- pStatus = #carded
- else
- pStatus = #greeted
- end if
- fixEventTriggers(me)
- goBase(me)
- else
- fixEventTriggers(me)
- approachAndGreet(me)
- end if
- pPostDrinkSpacing = seconds(currentLevel(#POSTDRINKANTICINTERVAL))
- getIntoxication(me)
- end
-
- on fixEventTriggers me
- pNoEventsDuringTest = 1
- show(me)
- pSpr.rect = rect(0, 0, 1, 1)
- updateStage()
- gotoFrame(pSpr, 1)
- updateStage()
- gotoFrame(pSpr, 2)
- updateStage()
- pNoEventsDuringTest = 0
- end
-
- on adjustFlashRect me, thisLabel, flashSubRect, CalcArbusRect
- global gFlashRects, gBarTopSprite
- thisChar = gFlashRects[pCharCode]
- if voidp(flashSubRect) then
- flashSubRect = thisChar[thisLabel]
- if flashSubRect = 0 then
- if (thisLabel = #base1) or (thisLabel = #tbase) then
- flashSubRect = thisChar[#Bases]
- else
- flashSubRect = thisChar[#default]
- end if
- end if
- end if
- newSpriteRect = offset(flashSubRect, pBigFlashRect.left, pBigFlashRect.top)
- specialOffset = getBarPositionOffset(gBarTopManager, pMyBarSlot)
- newSpriteRect.left = newSpriteRect.left + specialOffset
- newSpriteRect.right = newSpriteRect.right + specialOffset
- trimLeft = 0
- trimTop = 0
- if newSpriteRect.left < 0 then
- trimLeft = -newSpriteRect.left
- newSpriteRect.left = 0
- end if
- if newSpriteRect.top < 0 then
- trimTop = -newSpriteRect.top
- newSpriteRect.top = 0
- end if
- if newSpriteRect.right > 640 then
- newSpriteRect.right = 640
- end if
- barTopLimit = gBarTopSprite.top
- barBottomLimit = gBarTopSprite.bottom
- if newSpriteRect.bottom > barBottomLimit then
- if debug then
- put "Bottom of Rect should not be below bar in most cases. Potentential Problem:" && newSpriteRect.bottom
- end if
- else
- if newSpriteRect.bottom > ((barTopLimit + barBottomLimit) / 2) then
- if debug then
- put "Flash Rect intersects bar half way. It may be a problem." && newSpriteRect.bottom
- end if
- else
- if newSpriteRect.bottom > (barTopLimit + 10) then
- if debug then
- put "Flash Rect intersects bar no more than half way. It is probably okay." && newSpriteRect.bottom
- end if
- else
- if newSpriteRect.bottom < barTopLimit then
- if debug then
- put "Bottom of Flash rect (" && newSpriteRect.bottom & ") is above the bar. I'll EXTEND it."
- end if
- newSpriteRect.bottom = barTopLimit
- end if
- end if
- end if
- end if
- if CalcArbusRect then
- return [#rect: newSpriteRect, #left: trimLeft, #top: trimTop]
- else
- pSpr.rect = newSpriteRect
- end if
- centerPt = point(newSpriteRect.width / 2.0, newSpriteRect.height / 2.0)
- pSpr.viewH = flashSubRect.left + centerPt[1] + trimLeft
- pSpr.viewV = flashSubRect.top + centerPt[2] + trimTop
- end
-
- on showTree Msg
- end
-
- on startFlashAnim me, thisLabel
- alterQuality(me, #high)
- showTree(" startFlashAnim")
- if pStatus = #offStage then
- put "exiting offstage"
- exit
- end if
- adjustFlashRect(me, thisLabel)
- thisLabel = string(thisLabel)
- if findLabel(pSpr, thisLabel) then
- gotoFlashFrame(pSpr, thisLabel, 1)
- repeat with X = 1 to count(pLabels)
- if pLabels[X][#label] = thisLabel then
- foundit = 1
- pThrottleFrame = pLabels[X][#start]
- exit repeat
- end if
- end repeat
- if foundit then
- case pTurnOffAnim of
- #stationary:
- alterQuality(me, #high)
- forceNewAnimation(me)
- #dummy:
- nothing()
- otherwise:
- pThrottleTime = now()
- startAnimating(me, X)
- end case
- else
- badString = "Animation" && thisLabel && "not implemented for character" && pCharCode
- put "*************************** WARNING *******************" && badString
- debugAlert(badString)
- if thisLabel <> #base1 then
- goBase(me)
- end if
- end if
- else
- debugAlert("Should never get here -- Label" && thisLabel && "not found in Flash file for character" && pCharCode)
- pAnimating = 0
- end if
- end
-
- on doNextAction me
- showTree(" DoNextAction")
- if count(pStepsInCurrentAction) then
- deleteAt(pStepsInCurrentAction, 1)
- if count(pStepsInCurrentAction) then
- nextStepInAnim(me)
- else
- nextAction(me)
- nextAnim(me)
- end if
- else
- if count(pActionList) then
- nextAction(me)
- end if
- nextAnim(me)
- end if
- end
-
- on nextAction me
- global gDrinksServedThisLevel, gTotalAccuracy, gPearlyGates
- showTree(" NextAction")
- pTurnOffAnim = pActionList[1][#turnOffAnim]
- if count(pActionList) then
- deleteAt(pActionList, 1)
- stopAnimating(me)
- end if
- setTimeLastAction()
- case pTurnOffAnim of
- #bounceDone:
- call(#bounced, ancestor)
- showTree("#bounceDone")
- gBounceInProgress = 0
- characterLeft(me)
- #retreatDone:
- showTree("#retreatDone")
- hideMyGlass(me)
- characterLeft(me)
- #stationary:
- showTree("#stationary")
- stopAnimating(me)
- if othersBusy(me) = 0 then
- gMachineSpeed = #fast
- end if
- #orderDone:
- showTree("#orderDone")
- if pStatus <> #ordered then
- pStatus = #ordered
- pTimeOrdered = now()
- pWaitForDrinkStatus = #new
- end if
- repeat while soundPlaying(me)
- checkElapsedTime()
- updateStage()
- end repeat
- mShowMouth(me, 0)
- gotoFlashFrame(pSpr, "BASE1", 1)
- checkForSpecialRecipe(pRecipeID)
- case me.pIntoxication of
- #passedOut:
- voGuide = random(10)
- if voGuide >= 7 then
- nothing()
- else
- if voGuide >= 4 then
- managerVO(randomFromList(["V12", "W19", "W20"]))
- else
- if voGuide >= 2 then
- managerVO(randomFromList(["V10", "V11"]))
- else
- managerVO(randomFromList(["V16", "v06", "v07"]))
- end if
- end if
- end if
- end case
- #arriveDone:
- showTree("#arriveDone")
- resetNewCharacterTimer()
- pTimeApproached = now()
- pStatus = #greeting
- #greetDone:
- showTree("#greetDone")
- resetNewCharacterTimer()
- pTimeApproached = now()
- if me.pAlreadyCarded then
- if statusIs(me, [#approaching, #greeting, #greeted, #acknowledged]) then
- pStatus = #carded
- end if
- else
- pStatus = #greeted
- end if
- #heavenGreetDone:
- gPearlyGates = 2
- exit
- #doneDrinking:
- showTree("#doneDrinking")
- updateStage()
- showHandAndGlass(me, 0)
- updateStage()
- #doneServing:
- showTree("#doneServing")
- updateStage()
- showHandAndGlass(me, 0)
- updateStage()
- goBase(me)
- getIntoxication(me)
- priorIntoxication = me.pIntoxication
- incrementAlcohol(me, pLiquorGlass)
- gDrinksServedThisLevel = gDrinksServedThisLevel + 1
- gTotalAccuracy = gTotalAccuracy + pAccuracy
- if pAccuracy >= currentLevel(#accVhigh) then
- pLastDrinkTaste = #great
- else
- if pAccuracy >= currentLevel(#accHigh) then
- pLastDrinkTaste = #good
- else
- if pAccuracy >= ((currentLevel(#accHigh) + currentLevel(#accLow)) / 2) then
- pLastDrinkTaste = #okay
- else
- if pAccuracy >= currentLevel(#accLow) then
- pLastDrinkTaste = #poor
- else
- pLastDrinkTaste = #awful
- end if
- end if
- end if
- end if
- getIntoxication(me)
- if (priorIntoxication = #passedOut) and ((pLiquorGlass > 0) or (pJuiceGlass > 2.5)) then
- if pLiquorGlass > 0 then
- pLastDrinkResponse = #passOut
- else
- if pSourMilk then
- pLastDrinkResponse = #sick
- else
- if pJuiceGlass > 2.5 then
- pLastDrinkResponse = #nonalcoholic
- end if
- end if
- end if
- else
- case pLastDrinkTaste of
- #great:
- if pDifficulty > 5 then
- pLastDrinkResponse = #PDRINKD
- else
- pLastDrinkResponse = #PDRINKS
- end if
- #good:
- pLastDrinkResponse = #PDRINKS
- #okay:
- pLastDrinkResponse = #MDRINK
- #poor:
- pLastDrinkResponse = randomFromList([#NDRINKS, #NDRINKD])
- #awful:
- pLastDrinkResponse = #NDRINKZ
- end case
- if pSourMilk then
- pLastDrinkResponse = #sick
- else
- if pLiquorGlass > (3 * pLiquorRecipe) then
- pLastDrinkResponse = #puke
- else
- if pLiquorGlass > (2 * pLiquorRecipe) then
- pLastDrinkResponse = #NDRINKZ
- else
- if pLiquorGlass < (pLiquorRecipe / 2.5) then
- pLastDrinkResponse = #NDRINKZ
- end if
- end if
- end if
- end if
- end if
- case pLastDrinkResponse of
- #passOut, #sick, #puke:
- playAnim(me, #passOut, VOID, #donePassingOut, VOID, 1)
- gTipPending = 0
- #nonalcoholic:
- playAnim(me, #MDRINK, VOID, #doneNonalcoholic, VOID, 1)
- #NDRINKZ:
- pStatus = #served
- releaseFocus(me)
- playAnim(me, #NDRINKZ, #retreating, #retreatDone, VOID, 1)
- gTipPending = 0
- otherwise:
- playAnim(me, pLastDrinkResponse, VOID, #tip, VOID, 1)
- end case
- #doneNonalcoholic:
- showHandAndGlass(me, 0)
- goBase(me)
- pPatronGaveTip = 1
- praiseworthyAction(me)
- mSoberUp(me)
- pStatus = #served
- if not maxAutoAtBar(gBarTopManager) then
- newCharacterEnters(#ifServed)
- end if
- #donePassingOut:
- pStatus = #served
- resetIntoxication(me)
- addToPukatory(gBarTopManager, pMyBarSlot)
- if pLastDrinkResponse = #sick then
- managerVO(randomFromList(["v03", "w14", "w15"]))
- else
- if (random(3) = 1) and (gPlayerTips > 0) and (pLastDrinkResponse = #passOut) then
- managerVO(randomFromList(["V01", "V02"]))
- me.pBouncedPermanently = 1
- regTip(-currentLevel(#maxFastTip) * 2)
- else
- managerVO(randomFromList(["V04", "V05", "v13", "v14", "v15"]))
- regTip(-currentLevel(#maxFastTip))
- end if
- end if
- hideMyGlass(me)
- characterLeft(me)
- #tip:
- showTree("#tip")
- showHandAndGlass(me, 0)
- goBase(me)
- tip(me)
- pStatus = #served
- if not maxAutoAtBar(gBarTopManager) then
- newCharacterEnters(#ifServed)
- end if
- end case
- end
-
- on showHandAndGlass me, flag
- global gWellSprite
- specialOffset = getBarPositionOffset(gBarTopManager, pMyBarSlot)
- sendSprite(pGlassSpr, #mAdjustPosition, specialOffset)
- sendSprite(pHandSpr, #mAdjustPosition, specialOffset)
- pGlassSpr.visible = flag
- pHandSpr.visible = flag
- if gWellSprite.pWellSprite <> barSlotToGlassSprite(gBarTopManager, pMyBarSlot) then
- showBarGlass(gBarTopManager, pMyBarSlot, not flag)
- else
- end if
- end
-
- on soundPlaying me
- return soundBusy(pSoundChannel)
- end
-
- on playVO me, VOname, waitForSound, timing
- pWaitForVO = waitForSound
- calldebug(VOname, waitForSound, timing, me)
- if voidp(VOname) then
- exit
- end if
- pMouthTiming = timing
- if listp(pMouthTiming) then
- pMouthTimingCount = count(pMouthTiming)
- end if
- pLastTiming = 1
- soundFile = VOpath(pCharCode, VOname)
- if FileExists(soundFile) then
- if soundPlayfile(pSoundChannel, soundFile) then
- repeat while not soundBusy(pSoundChannel)
- end repeat
- if pWaitForVO then
- gotoFlashFrame(pSpr, "Tbase", 0)
- mShowMouth(me, 1)
- end if
- end if
- else
- doNextAction(me)
- pWaitForVO = 0
- if authoring() then
- put "Missing sound file" && soundFile
- end if
- end if
- end
-
- on playAnim me, animList, newStatusList, turnOffList, forceMatchingAction, delayAction
- showTree("playAnim" && animList && newStatusList && turnOffList && forceMatchingAction)
- setTimeLastAction()
- if pStatus = #offStage then
- exit
- end if
- if not listp(animList) then
- animList = [animList]
- end if
- if not listp(newStatusList) then
- newStatusList = [newStatusList]
- end if
- if not listp(turnOffList) then
- turnOffList = [turnOffList]
- end if
- animCount = count(animList)
- newStatusCount = count(newStatusList)
- turnOffCount = count(turnOffList)
- if animCount > newStatusCount then
- repeat with X = newStatusCount to animCount
- add(newStatusList, VOID)
- end repeat
- end if
- if animCount > turnOffCount then
- repeat with X = turnOffCount to animCount
- add(turnOffList, VOID)
- end repeat
- end if
- repeat with X = 1 to count(animList)
- add(pActionList, [#action: animList[X], #turnOffAnim: turnOffList[X], #startStatus: newStatusList[X]])
- end repeat
- if not voidp(forceMatchingAction) then
- nextAnim(me, [[#action: pLastDrinkType, #turnOffAnim: turnOffList[1], #startStatus: newStatusList[1]]], pDrinkOrder)
- else
- if not delayAction then
- nextAnim(me)
- end if
- end if
- end
-
- on nextAnim me, action, steps
- global gPearlyGates, gUserQuitFlag
- if inMenuMode() then
- if (gPearlyGates > 0) and (pCharCode <> #BC) then
- abort()
- exit
- else
- if not gUserQuitFlag then
- abort()
- exit
- end if
- end if
- end if
- showTree(" NextAnim")
- if count(pActionList) then
- pTurnOffAnim = pActionList[1][#turnOffAnim]
- newStatus = pActionList[1][#startStatus]
- if not voidp(newStatus) then
- pStatus = newStatus
- end if
- else
- pTurnOffAnim = VOID
- end if
- if count(pActionList) = 0 then
- if (pTurnOffAnim <> #stationary) and statusNot(me, [#offStage, #approaching, #retreating, #bouncing]) then
- goBase(me)
- else
- nothing()
- end if
- exit
- end if
- if not voidp(action) then
- pActionList = action
- pStepsInCurrentAction = duplicate(steps)
- if not listp(pStepsInCurrentAction) then
- debugAlert("Invalid actions to perform for" && pActionList[1][#action] && pStepsInCurrentAction)
- exit
- end if
- nextStepInAnim(me)
- exit
- end if
- thisAction = pActionList[1][#action]
- matches = []
- lowestDifficulty = 99
- lastResort = []
- repeat with X = 1 to count(me.pCharacterActions)
- if getPropAt(me.pCharacterActions, X) = thisAction then
- stepsInThisAction = me.pCharacterActions[X][1]
- includeMe = 1
- repeat with Y = 1 to count(stepsInThisAction)
- if getPropAt(stepsInThisAction, Y) = #RID then
- thisRecipe = getRecipe(stepsInThisAction[Y])
- if listp(thisRecipe) then
- DIFFICULTY = integer(thisRecipe[#DIFFICULTY])
- MAXDRINKDIFF = currentLevel(#MAXDRINKDIFF)
- if beyondMinTips() then
- MAXDRINKDIFF = max(MAXDRINKDIFF, 5)
- end if
- if DIFFICULTY > MAXDRINKDIFF then
- if DIFFICULTY < lowestDifficulty then
- lowestDifficulty = DIFFICULTY
- lastResort = stepsInThisAction
- end if
- includeMe = 0
- exit repeat
- else
- includeMe = 1
- end if
- next repeat
- end if
- includeMe = 0
- exit repeat
- end if
- end repeat
- if includeMe then
- add(matches, stepsInThisAction)
- end if
- end if
- end repeat
- if (count(matches) = 0) and (lastResort <> []) then
- add(matches, lastResort)
- end if
- if count(matches) = 0 then
- debugAlert("No entry in the database for action" && thisAction && "for this character" && pCharCode)
- deleteAt(pActionList, 1)
- exit
- else
- pStepsInCurrentAction = duplicate(randomFromList(matches))
- case thisAction of
- #DRINKS, #DRINKD, #DRINKDD:
- pDrinkOrder = duplicate(pStepsInCurrentAction)
- getRecipeInfo(me, pDrinkOrder[#RID], 1)
- end case
- end if
- nextStepInAnim(me)
- end
-
- on setAnimationPlane me, plane
- pSpr.locZ = plane
- pMouthSpr.locZ = plane + 1
- end
-
- on nextStepInAnim me
- showTree(" NextStepInAnim")
- case getPropAt(pStepsInCurrentAction, 1) of
- #anim:
- animType = symbol(pStepsInCurrentAction[1])
- if debug then
- put "Next Step in Anim is" && animType
- end if
- case animType of
- #SMOVE, #sBlotto, #beckon, #pdrink:
- if pCharCode = #OG then
- newPlane = 78
- else
- newPlane = barSlotToSprite(numBarSlots()) + 1
- end if
- #retreat:
- if pCharCode = #OG then
- newPlane = 90
- else
- newPlane = barSlotToSprite(1) - 1
- end if
- #approach:
- newPlane = barSlotToSprite(1) - 1
- #bounce:
- newPlane = barSlotToSprite(1) - 1
- sendSprite(gArbusSprite, #setAnimationPlane, newPlane)
- sendSprite(gArbusSprite, #replicate, pSpr)
- #base1, #drink, #tbase, #DrinkL, #DrinkJ:
- newPlane = me.spriteNum
- otherwise:
- newPlane = barSlotToSprite(numBarSlots()) + 1
- end case
- setAnimationPlane(me, newPlane)
- startFlashAnim(me, animType)
- updateStage()
- #vo:
- setAnimationPlane(me, me.spriteNum)
- alterQuality(me, #high)
- adjustFlashRect(me, #tbase)
- showTree(" nextStepInAnim - startFlashVO")
- VOname = pStepsInCurrentAction[1]
- if debug then
- put "Reached #VO in nextAnim" && VOname
- end if
- playVO(me, VOname, 1, me.pMouthList[symbol(VOname)])
- startVOing(me)
- #RID:
- showTree(" nextStepInAnim - hit recipe ID")
- doNextAction(me)
- otherwise:
- put "Not a #rid, #vo or #anim" && getPropAt(pStepsInCurrentAction, 1)
- doNextAction(me)
- end case
- end
-
- on resetRecipe me
- setRecipePatronName(pMyBarSlot, pPatronName)
- setRecipeDrinkName(pMyBarSlot, pRecipeName)
- refreshRecipeWindow()
- end
-
- on mForceRecipe me, newRecID
- pForcedRecipe = newRecID
- takeForcedOrder(me)
- end
-
- on takeForcedOrder me
- if ((me.pAlreadyCarded = 1) and (pStatus = #carded)) or (pStatus = #ordered) then
- pRecipeID = pForcedRecipe
- getRecipeInfo(me, pForcedRecipe)
- pStatus = #ordered
- checkForSpecialRecipe(pForcedRecipe)
- pTimeOrdered = now()
- pWaitForDrinkStatus = #new
- thisRecipe = getRecipe(pForcedRecipe)
- if characterHasRecipe(me) then
- if statusNot(me, [#ordered, #serving, #served, #bouncing, #retreating, #offStage]) then
- newStatus = #ordering
- else
- newStatus = pStatus
- end if
- playAnim(me, pLastDrinkType, newStatus, #orderDone, pDrinkOrder)
- else
- drinkName = thisRecipe[#DisplayException]
- if drinkName = "Same" then
- drinkName = thisRecipe[#drinkName]
- end if
- case drinkName.char[1] of
- "a", "e", "i", "o", "u":
- article = "an"
- otherwise:
- article = "a"
- end case
- startText = randomFromList(["Give me", "I'll have"])
- prompt = startText && article && drinkName & "."
- resetRecipe(me)
- updateStage()
- MUIalert(prompt, "Customer Drink Order", #note, #Ok)
- end if
- end if
- end
-
- on randomFromWeightedActionList me, pickFrom
- matches = []
- weightList = []
- repeat with X = 1 to count(pickFrom)
- add(weightList, 0)
- end repeat
- repeat with X = 1 to count(me.pCharacterActions)
- thisAction = getPropAt(me.pCharacterActions, X)
- Match = getOne(pickFrom, thisAction)
- if Match then
- weightList[Match] = weightList[Match] + 1
- end if
- end repeat
- return randomFromWeightedList(weightList, pickFrom)
- end
-
- on characterHasRecipe me
- matches = []
- repeat with X = 1 to count(me.pCharacterActions)
- thisDrinkType = getPropAt(me.pCharacterActions, X)
- if getOne([#DRINKS, #DRINKD, #DRINKDD], thisDrinkType) then
- stepsInThisAction = me.pCharacterActions[X][1]
- repeat with Y = 1 to count(stepsInThisAction)
- if getPropAt(stepsInThisAction, Y) = #RID then
- if pForcedRecipe = stepsInThisAction[Y] then
- pStepsInCurrentAction = duplicate(stepsInThisAction)
- pDrinkOrder = duplicate(pStepsInCurrentAction)
- pLastDrinkType = thisDrinkType
- getRecipeInfo(me, pDrinkOrder[#RID], 0)
- return 1
- end if
- end if
- end repeat
- end if
- end repeat
- return 0
- end
-
- on recipes me, inSound
- global gPauseState
- if gPauseState then
- alertBeep()
- exit
- end if
- if voidp(inSound) then
- inSound = "recipe_sound"
- end if
- waitCursor()
- if recipeWindowAtLabel("quickView") then
- toggleRecipeWindow("quickView")
- else
- toggleRecipeWindow("current" & pMyBarSlot, VOID, 1)
- end if
- if draggingAnything() then
- hideCursor()
- else
- resetCursor()
- end if
- end
-
- on getRecipeInfo me, recipeID, refresh
- global gRecipeWindow
- pRecipeID = recipeID
- temp = getRecipe(recipeID)
- if listp(temp) then
- pDifficulty = integer(temp[#DIFFICULTY])
- pDrinkImpatience = diffFactor(pDifficulty)
- end if
- recipeInfo = createRecipe(recipeID)
- pRecipeName = recipeInfo[#name]
- setRecipeDrinkName(pMyBarSlot, pRecipeName)
- if refresh then
- refreshRecipeWindow()
- end if
- end
-
- on charm me, inSound
- global gPlayerGender
- if bouncingOrRetreating(me) then
- exit
- end if
- if busy(me) then
- if statusNot(me, [#greeting, #greeted, #carded, #ordered, #served]) then
- pleaseWait()
- exit
- end if
- end if
- if voidp(inSound) then
- inSound = "charm_sound"
- end if
- if me.pCharmed > me.pNumVisits then
- voList = ["F01", "F04"]
- if gPlayerGender = #male then
- add(voList, "F02")
- add(voList, "F03")
- end if
- managerVO(randomFromList(voList))
- pCharmedPoints = pCharmedPoints - 2
- exit
- end if
- case me.pCharmed of
- 0:
- anim = #flatter
- points = 1
- 1:
- case me.pLikesGender = gPlayerGender of
- 1:
- anim = #PCharm
- points = 2
- 0:
- anim = #nCharm
- points = -2
- end case
- otherwise:
- case me.pLikesGender = gPlayerGender of
- 1:
- anim = #XPCHARM
- points = 3
- 0:
- anim = #XNCHARM
- points = -3
- end case
- end case
- pCharmedPoints = pCharmedPoints + points
- if busy(me) then
- goBase(me)
- end if
- me.pCharmed = me.pCharmed + 1
- soundFX(inSound, 0, 0)
- playAnim(me, anim)
- end
-
- on forceNewAnimation me
- stopAnimating(me)
- pWaitForVO = 0
- pMouthTiming = VOID
- mShowMouth(me, 0)
- pActionList = []
- pStepsInCurrentAction = [:]
- end
-
- on statusNot me, statuses
- return not getOne(statuses, pStatus)
- end
-
- on statusIs me, statuses
- return getOne(statuses, pStatus)
- end
-
- on takeOrder me
- global gLastCurrent, gGaveOrderHint
- if bouncingOrRetreating(me) then
- alertBeep()
- exit
- end if
- if pStatus = #ordering then
- alertBeep()
- exit
- end if
- if statusNot(me, [#ordered, #serving, #served, #bouncing, #retreating, #offStage]) then
- newStatus = #ordering
- else
- newStatus = pStatus
- end if
- if pStatus <> #ordered then
- pTimeOrdered = now()
- end if
- stopSound(me)
- goBase(me)
- gGaveOrderHint = 1
- if voidp(pLastDrinkType) then
- case me.pIntoxication of
- #sober, #buzzed:
- pLastDrinkType = randomFromWeightedActionList(me, [#DRINKD, #DRINKS])
- #blotto:
- pLastDrinkType = randomFromWeightedActionList(me, [#DRINKD, #DRINKS])
- #passedOut:
- pLastDrinkType = randomFromList([#DRINKD, #DRINKDD])
- end case
- refreshRecipes(pMyBarSlot)
- playAnim(me, pLastDrinkType, newStatus, #orderDone)
- me.pHasEverOrdered = 1
- else
- if gLastCurrent <> pMyBarSlot then
- refreshRecipes(pMyBarSlot)
- end if
- playAnim(me, pLastDrinkType, newStatus, #orderDone, pDrinkOrder)
- end if
- end
-
- on order me, inSound
- global gPlayerCardWarnings, gServedUnderage
- if bouncingOrRetreating(me) then
- alertBeep()
- exit
- end if
- if voidp(inSound) then
- inSound = "order_sound"
- end if
- if inRecipeMode() then
- if not me.pAlreadyCarded then
- remindAboutID()
- exit
- end if
- if voidp(pForcedRecipe) or (pForcedRecipe = 0) then
- managerVO(randomFromList(["Y09", "Y10", "Y11", "Y12", "Y13"]))
- showRecipeAZ()
- else
- takeForcedOrder(me)
- end if
- exit
- end if
- if not me.pAlreadyCarded then
- if gGameLevel = 1 then
- remindAboutID()
- else
- if gPlayerCardWarnings < 1 then
- managerVO("E02", 1)
- else
- managerVO("E03", 1)
- managerVO("E05")
- gServedUnderage = 1
- endOfLevel()
- exit
- end if
- gPlayerCardWarnings = gPlayerCardWarnings + 1
- end if
- else
- if not me.pOver21 then
- gServedUnderage = 1
- stopPatronSounds()
- managerVO(randomFromList(["E03", "w05", "w06", "w07", "w10"]), 1, 0, 1, 1)
- endOfLevel()
- else
- if pStatus = #ordering then
- nothing()
- else
- if pStatus = #ordered then
- soundFX(inSound, 0, 0)
- takeOrder(me)
- else
- if (pStatus = #served) or (pStatus = #serving) then
- managerVO("T06")
- else
- if pStatus = #carded then
- takeOrder(me)
- else
- if pStatus = #greeting then
- takeOrder(me)
- else
- debugAlert("Inappropriate status" && pStatus)
- end if
- end if
- end if
- end if
- end if
- end if
- end if
- end
-
- on stopSound me
- sound stop pSoundChannel
- end
-
- on serve me, inSound, automaticServe
- global gMixingVesselsList
- if bouncingOrRetreating(me) then
- alertBeep()
- exit
- end if
- if voidp(inSound) then
- inSound = "serve_sound"
- end if
- case pStatus of
- #served:
- soundFX(inSound, 0, 0)
- managerVO(randomFromList(["T03", "I04"]))
- if not busy(me) then
- sipDrink(me)
- end if
- #serving, #ordering:
- alertBeep()
- exit
- #ordered:
- soundFX(inSound, 0, 0)
- if getBarTopGlass(gBarTopManager, pMyBarSlot) = #none then
- remindToChooseGlass(1)
- exit
- else
- if count(patronToGlass(me.spriteNum).pContents) = 0 then
- managerVO("T05")
- exit
- end if
- end if
- if (getActiveGlass() = patronToGlass(me.spriteNum)) or not automaticServe then
- emptyGlasses(1, 1)
- end if
- if timeLeftOnThisLevel() > 0 then
- gTipPending = 1
- end if
- incrementDrinks(me)
- pTimeServed = now()
- setTimeLastAction()
- pStatus = #serving
- pDrinksBeenServed = 1
- forceNewAnimation(me, #serving)
- goBase(me)
- score = scoreDrink(me)
- pPoints = score[#points]
- pMaxPoints = score[#maxPoints]
- pAccuracy = score[#accuracy]
- pDifficulty = score[#DIFFICULTY]
- pSourMilk = score[#sourMilk]
- pLiquorGlass = score[#liquorGlass]
- pLiquorRecipe = score[#liquorRecipe]
- pJuiceGlass = score[#juiceGlass]
- if pLiquorGlass > (3 * pLiquorRecipe) then
- drinkAll = 1
- else
- drinkAll = 0
- end if
- sendSprite(barSlotToGlassSprite(gBarTopManager, pMyBarSlot), #mReduceLiquid, drinkAll)
- playAnim(me, #drink, #serving, #doneServing)
- releaseFocus(me)
- calcPostDrinkStuff(me)
- otherwise:
- soundFX(inSound, 0, 0)
- if me.pAlreadyCarded then
- remindToTakeOrder()
- else
- remindAboutID()
- end if
- end case
- end
-
- on currentPatience me
- global gCurrentSong
- pPatience = me.pImpatience * max(0.5, min(power(currentLevel(#CHARMINFPATIENCE), pCharmedPoints), 3))
- if me.pDrinkTicket > 0 then
- pPatience = pPatience * currentLevel(#TIXINFPATIENCE)
- end if
- fav = me.pFavoriteSong
- anti = me.pHatedSong
- if gCurrentSong = fav then
- pPatience = pPatience * currentLevel(#DANCEINFPATIENCE)
- end if
- return pPatience
- end
-
- on beckon me
- playAnim(me, #beckon)
- end
-
- on timeElapsed me
- global gNoChaos, gDrinkDebug
- if gNoChaos or bouncingOrRetreating(me) then
- exit
- end if
- if busy(me) then
- exit
- end if
- beenWaiting = timeSinceLastAction(me)
- case pStatus of
- #approaching, #greeting, #bouncing, #retreating:
- exit
- #greeted, #acknowledged, #carded:
- waitToOrder(me)
- #ordering:
- nothing()
- #ordered:
- waitForDrink(me)
- #serving:
- nothing()
- #served:
- beenWaiting = timeSinceServed(me)
- if beenWaiting < pPostDrinkSpacing then
- nothing()
- else
- if busy(me) then
- nothing()
- else
- if timeSinceLastAction(me) < pPostDrinkSpacing then
- nothing()
- else
- if not pPostDrinkStay then
- retreat(me)
- else
- if beenWaiting > pPostDrinkPatience then
- retreat(me)
- else
- if (pMyBarSlot = 2) and ((pCharCode = #BC) or (pCharCode = #LM)) then
- retreat(me)
- else
- if currentLevel(#postDrinkAnticChance) > random(100) then
- performAntic(me)
- else
- if getBarTopGlass(gBarTopManager, pMyBarSlot) = #none then
- performAntic(me)
- else
- sipDrink(me)
- end if
- end if
- end if
- end if
- end if
- end if
- end if
- end if
- #offStage:
- nothing()
- otherwise:
- put "unknown status" && pStatus
- end case
- end
-
- on impatientForDrink me
- playAnim(me, randomFromList([#WDRINKS, #WDRINKD]))
- end
-
- on impatientToOrder me
- playAnim(me, randomFromList([#WORDERS, #WORDERD]))
- end
-
- on deferAction me
- if busy(me) then
- return 1
- end if
- case gMachineSpeed of
- #verySlow, #slow:
- if othersBusy(me) > 0 then
- return 1
- end if
- #medium:
- if (othersBusy(me, [#approaching, #greeting, #retreating]) > 1) or gBounceInProgress then
- return 1
- end if
- #fast:
- return 0
- otherwise:
- debugAlert("Uknown machineSpeed" && gMachineSpeed)
- end case
- end
-
- on waitToOrder me
- beenHere = timeSinceApproached(me)
- if deferAction(me) then
- if (beenHere > impatienceOrder(me, pOrderLeave)) and (pWaitToOrderStatus = #Impatient) then
- nothing()
- else
- exit
- end if
- end if
- if me.pIntoxication = #passedOut then
- if timeSinceLastAction(me) > pPostDrinkSpacing then
- performAntic(me)
- end if
- else
- if (beenHere > impatienceOrder(me, pOrderLeave)) and (pWaitToOrderStatus = #Impatient) then
- pWaitToOrderStatus = #disgusted
- if inRecipeMode() or (gPlayerTips = 0) then
- pWaitToOrderStatus = #Impatient
- impatientToOrder(me)
- pTimeApproached = now()
- else
- hideMyGlass(me)
- releaseFocus(me)
- playAnim(me, #WORDERZ, #retreating, #retreatDone)
- end if
- else
- if (beenHere > impatienceOrder(me, pOrderImpatient)) and (pWaitToOrderStatus = #antic) then
- pWaitToOrderStatus = #Impatient
- impatientToOrder(me)
- else
- if (beenHere > impatienceOrder(me, pOrderAntic)) and (pWaitToOrderStatus = #beckoned) then
- pWaitToOrderStatus = #antic
- case gMachineSpeed of
- #verySlow:
- anticChance = 0
- #slow:
- anticChance = currentLevel(#orderAnticChance) / 2
- otherwise:
- anticChance = currentLevel(#orderAnticChance)
- end case
- if anticChance > random(100) then
- performAntic(me)
- else
- impatientToOrder(me)
- end if
- else
- if (beenHere > impatienceOrder(me, pOrderBeckon)) and (pWaitToOrderStatus = #new) then
- pWaitToOrderStatus = #beckoned
- case gMachineSpeed of
- #verySlow:
- exit
- end case
- beckon(me)
- end if
- end if
- end if
- end if
- end if
- end
-
- on hideMyGlass me
- end
-
- on waitForDrink me
- beenHere = timeSinceOrdered(me)
- if deferAction(me) then
- if (beenHere > impatienceDrink(me, pServeLeave)) and (pWaitForDrinkStatus = #Impatient) then
- nothing()
- else
- exit
- end if
- end if
- if me.pIntoxication = #passedOut then
- if timeSinceLastAction(me) > pPostDrinkSpacing then
- performAntic(me)
- end if
- else
- if (beenHere > impatienceDrink(me, pServeLeave)) and (pWaitForDrinkStatus = #Impatient) then
- pWaitForDrinkStatus = #disgusted
- if inRecipeMode() or (gPlayerTips = 0) then
- pWaitForDrinkStatus = #Impatient
- impatientForDrink(me)
- pTimeOrdered = now()
- else
- if mIsHoldingLiquid(barSlotToGlassSprite(gBarTopManager, pMyBarSlot)) > 0 then
- pWaitForDrinkStatus = #Impatient
- serve(me, VOID, 1)
- else
- hideMyGlass(me)
- releaseFocus(me)
- playAnim(me, #WDRINKZ, #retreating, #retreatDone)
- end if
- end if
- else
- if (beenHere > impatienceDrink(me, pServeImpatient)) and (pWaitForDrinkStatus = #antic) then
- pWaitForDrinkStatus = #Impatient
- impatientForDrink(me)
- else
- if (beenHere > impatienceDrink(me, pServeAntic)) and (pWaitForDrinkStatus = #new) then
- pWaitForDrinkStatus = #antic
- case gMachineSpeed of
- #verySlow:
- anticChance = 0
- #slow:
- anticChance = currentLevel(#serveAnticChance) / 2
- otherwise:
- anticChance = currentLevel(#serveAnticChance)
- end case
- if anticChance > random(100) then
- performAntic(me)
- else
- impatientForDrink(me)
- end if
- end if
- end if
- end if
- end if
- end
-
- on impatienceOrder me, someTime
- return someTime * currentPatience(me)
- end
-
- on impatienceDrink me, someTime
- return someTime * currentPatience(me) * pDrinkImpatience
- end
-
- on performAntic me
- case me.pIntoxication of
- #sober:
- playAnim(me, #ASOBER)
- #buzzed:
- playAnim(me, #ABUZZ)
- #blotto:
- playAnim(me, #ABLOTTO)
- #passedOut:
- playAnim(me, randomFromWeightedActionList(me, [#ABLOTTO, #ABUZZ]))
- end case
- end
-
- on hide me
- pSpr.imageEnabled = 0
- pSpr.rect = rect(0, 0, 1, 1)
- end
-
- on show me
- pSpr.imageEnabled = 1
- end
-
- on praiseworthyAction me, tip20
- thisTip = randomBetween(integer(currentLevel(#maxSlowTip)), integer(currentLevel(#MAXAVERAGETIP)))
- thisTip = min(thisTip, 20)
- if (tip20 = 1) or (random(5) = 1) then
- voList = ["v08", "v09"]
- someTip = 20
- managerVO(randomFromList(voList), 1, 0, 1)
- regTip(someTip)
- else
- voList = ["w11", "w13"]
- someTip = thisTip
- regTip(someTip)
- managerVO(randomFromList(voList))
- end if
- end
-
- on characterLeft me
- global gGameTips, gPearlyGates, gUserQuitFlag
- stopAnimating(me)
- hide(me)
- if the number of member (pCharCode & "_id") > 0 then
- unLoad(member(pCharCode & "_id"))
- showMemoryStatus()
- end if
- if me.pBouncedPermanently then
- if me.pOver21 then
- else
- praiseworthyAction(me, 1)
- end if
- else
- if (pWaitToOrderStatus = #disgusted) and me.pAlreadyCarded and not me.pOver21 then
- voList = ["w11", "w13"]
- if not gPearlyGates and not gUserQuitFlag then
- managerVO(randomFromList(voList))
- end if
- else
- if (pLastDrinkResponse = #sick) or (pLastDrinkResponse = #passOut) or (pLastDrinkResponse = #nonalcoholic) or (pLastDrinkResponse = #puke) then
- nothing()
- else
- if (pWaitToOrderStatus = #disgusted) or (pWaitForDrinkStatus = #disgusted) or (pLastDrinkTaste = #awful) then
- voList = ["L01", "L02", "L03"]
- if gGameTips then
- add(voList, "u14")
- end if
- if not gPearlyGates and not gUserQuitFlag then
- if gGameLevel < 3 then
- managerVO(randomFromList(voList))
- end if
- end if
- resetForcedCharacterTimer()
- end if
- end if
- end if
- end if
- releaseFocus(me)
- removeCharacterTraces(me)
- removeBarTopCharacter(gBarTopManager, pMyBarSlot)
- releaseFocus(me)
- if (pPatronGaveTip and not maxAutoAtBar(gBarTopManager)) or (numberAtBar(gBarTopManager) = 0) then
- if not inTestMode() then
- newCharacterEnters(#ifServed)
- end if
- end if
- end
-
- on stopAnimating me
- showTree("stopAnimating")
- pAnimating = 0
- mShowMouth(me)
- showHandAndGlass(me, 0)
- stopSound(me)
- removeFromActorList(pSpr)
- end
-
- on startAnimating me, X
- showTree(" startAnimating")
- pAnimating = X
- addToActorList(pSpr)
- end
-
- on startVOing me
- showTree(" startVOing")
- addToActorList(pSpr)
- end
-
- on retreat me
- hideMyGlass(me)
- releaseFocus(me)
- playAnim(me, #retreat, #retreating, #retreatDone)
- end
-
- on releaseFocus me
- if pMyBarSlot = getActiveSlot(gBarTopManager) then
- makePatronActive()
- end if
- end
-
- on retreating me
- return pStatus = #retreating
- end
-
- on bouncingOrRetreating me
- return statusIs(me, [#retreating, #bouncing])
- end
-
- on toughLove me, inSound
- if gBounceInProgress then
- alertBeep()
- pleaseWait("MO3")
- exit
- end if
- if voidp(inSound) then
- inSound = "bounce_soundold"
- end if
- case pStatus of
- #offStage, #greeting, #approaching:
- alertBeep()
- pleaseWait("M02")
- #retreating:
- alertBeep()
- exit
- #bouncing:
- debugAlert("Should never get here - Should be tracked to bouncing up above.")
- #greeted, #acknowledged, #carded, #ordering, #ordered, #served, #serving:
- soundFX(inSound, 0, 0)
- goBase(me)
- forceNewAnimation(me, #bouncing)
- gBounceInProgress = 1
- releaseFocus(me)
- playAnim(me, #bounce, #bouncing, #bounceDone)
- otherwise:
- alertBeep()
- put "Unknown status while trying to bounce"
- end case
- end
-
- on findClosestMatch me
- global gRecipes, gFindClosest
- if inRecipeMode() and gFindClosest then
- waitCursor()
- bestAccuracy = 0
- bestMatchAccuracy = 0
- bestPoints = 0
- bestMatchPoints = 0
- repeat with X = 1 to count(gRecipes)
- matchRecipe = gRecipes[X]
- scoring = rateDrink(me, matchRecipe)
- if scoring[#accuracy] > bestAccuracy then
- bestAccuracy = scoring[#accuracy]
- bestMatchAccuracy = matchRecipe
- end if
- if scoring[#points] > bestPoints then
- bestPoints = scoring[#points]
- bestMatchPoints = matchRecipe
- end if
- end repeat
- resetCursor()
- MUIalert("Most accurate match" && bestAccuracy && bestMatchAccuracy[#drinkName])
- MUIalert("Most points scored" && bestPoints && bestMatchPoints[#drinkName])
- end if
- end
-
- on scoreDrink me
- clearDrinkDisplay()
- findClosestMatch(me)
- matchRecipe = getRecipe(pRecipeID)
- return rateDrink(me, matchRecipe)
- end
-
- on rateDrink me, matchRecipe
- global gRecipes
- points = 0
- maxPoints = 0
- DIFFICULTY = 0
- accuracy = 0
- liquorRecipe = 0
- agitated = 0
- carbonated = 0
- iceAdded = 0
- beforeIce = 0
- loseAgitatePoints = 0
- loseIcePoints = 0
- myContents = patronToGlass(me.spriteNum).pContents
- liquorGlass = calcLiquorContents(myContents)
- juiceGlass = calcWimpyContents(myContents)
- reportDrink("Eval. Rec ID:" && integer(pRecipeID) & "," && matchRecipe[#drinkName] & ", Diff.:" && integer(matchRecipe[#DIFFICULTY]))
- repeat with X = 1 to count(matchRecipe)
- thisProp = getPropAt(matchRecipe, X)
- thisValue = matchRecipe[X]
- case thisProp of
- #RECID:
- recipeID = integer(thisValue)
- #drinkName:
- drinkName = thisValue
- #DIFFICULTY:
- DIFFICULTY = integer(thisValue)
- #NOTES:
- nothing()
- #ingredients:
- repeat with thisIng in thisValue
- maxPoints = maxPoints + thisIng[#p]
- reportDrink(getNameByID(thisIng[#INGID]) && "worth" && thisIng[#p] && "points for quantity" && thisIng[#q])
- checkForLiquor = findingredientbyid(thisIng[#INGID])
- if checkForLiquor = #beer then
- liquorRecipe = liquorRecipe + (thisIng[#q] * 2.0)
- next repeat
- end if
- if isLiquor(checkForLiquor) then
- liquorRecipe = liquorRecipe + thisIng[#q]
- end if
- end repeat
- #SPECIAL_CASE, #DisplayException:
- nothing()
- otherwise:
- put "Unknown data type in recipes" && thisProp
- end case
- end repeat
- reportDrink("Evaluating" && myContents)
- repeat with X = 1 to count(myContents)
- ingredient = getPropAt(myContents, X)
- ingInfo = findIngredientInRecipe(matchRecipe, ingredient)
- altInfo = isAlternateInRecipe(matchRecipe, ingredient)
- case ingredient of
- #Muddle, #coat_and_rim:
- put "Muddle and Coat & Rim not implemented"
- #blend, #shake, #stir, #shaker, #blender, #mixingGlass:
- Quantity = 1
- points = mEvaluateIfPrimaryOrSubstituteAvoidDupes(me, matchRecipe, ingredient, "vessel", points, myContents)
- if getOne([#shake, #blend], ingredient) and carbonated then
- agitated = 1
- if not voidp(ingInfo) then
- loseAgitatePoints = ingInfo[#p]
- end if
- end if
- #iceNonGlass:
- Quantity = myContents[X]
- if voidp(ingInfo) then
- reportDrink("Void icenonglass")
- Quantity = 1.0
- else
- points = points + ingInfo[#p]
- reportDrink(ingInfo[#p] && "points for correct" && ingredient)
- end if
- #olive, #lemonWedge, #orangeWedge, #limeWedge, #cherry, #limetwist, #lemontwist:
- points = mEvaluateIfPrimaryOrSubstitute(me, matchRecipe, ingredient, "garnish", points)
- otherwise:
- if isCarbonated(ingredient) then
- carbonated = 1
- end if
- if ingredient = #ice then
- if not voidp(ingInfo) then
- loseIcePoints = ingInfo[#p]
- end if
- iceAdded = 1
- else
- if iceAdded = 0 then
- beforeIce = 1
- end if
- end if
- Quantity = myContents[X]
- if voidp(ingInfo) then
- points = points - (3 * Quantity)
- reportDrink("Lost" && 3 * Quantity && "points for wrong ingredient" && getname(ingredient))
- else
- if Quantity = 0 then
- percentCorrect = 0
- else
- percentCorrect = 1.0 - (abs(ingInfo[#q] - Quantity) / float(Quantity))
- end if
- points = points + (ingInfo[#p] * percentCorrect)
- reportDrink(ingInfo[#p] * percentCorrect && "points for" && percentCorrect & "% correct" && getname(ingredient))
- end if
- end case
- end repeat
- glassType = getBarTopGlass(gBarTopManager, pMyBarSlot)
- if glassType <> #beer then
- points = mEvaluateIfPrimaryOrSubstitute(me, matchRecipe, glassType, "glass", points)
- end if
- points = max(0, points)
- if maxPoints = 0 then
- reportDrink("Pointless recipe" && recipeID)
- accuracy = 0
- else
- accuracy = min(1.0, float(points) / maxPoints)
- end if
- reportDrink("Accuracy" && accuracy && "(" & points && "out of" && maxPoints & ")")
- if authoring() and debug then
- MUIalert("Drink mixing accuracy" && accuracy && "(" & points && "out of" && maxPoints & ")")
- end if
- sourMilk = milkWillSour(myContents, matchRecipe)
- if agitated then
- if loseAgitatePoints = 0 then
- loseAgitatePoints = 5
- end if
- if pRecipeID = 96 then
- reportDrink("Agitating carbonated liquid okay for Sweet Tart")
- else
- points = points - loseAgitatePoints
- reportDrink("Losing points for agitating carbonated liquid" && loseAgitatePoints)
- end if
- end if
- if beforeIce and iceAdded then
- if loseIcePoints = 0 then
- loseIcePoints = 5
- end if
- reportDrink("Losing points for adding ice after contents" && loseIcePoints)
- points = points - loseIcePoints
- end if
- scoring = [#points: points, #maxPoints: maxPoints, #accuracy: accuracy, #DIFFICULTY: DIFFICULTY, #sourMilk: sourMilk, #liquorGlass: liquorGlass, #liquorRecipe: liquorRecipe, #juiceGlass: juiceGlass]
- if debug then
- put "Scoring" && scoring
- end if
- return scoring
- end
-
- on mEvaluateIfPrimaryOrSubstitute me, matchRecipe, ingredient, textName, points
- global gIngredients
- ingInfo = findIngredientInRecipe(matchRecipe, ingredient)
- if voidp(ingInfo) then
- substitutesFor = isAlternateInRecipe(matchRecipe, gIngredients[ingredient][#INGID])
- if count(substitutesFor) then
- repeat with substituteGlassOrGarnish in substitutesFor
- ingInfo = findIngredientInRecipe(matchRecipe, substituteGlassOrGarnish[#ingName])
- if not voidp(ingInfo) then
- partialPoints = ingInfo[#p] * substituteGlassOrGarnish[#pA]
- reportDrink("Earned" && partialPoints && "points for substitute" && textName & ":" && ingredient && "instead of" && substituteGlassOrGarnish[#ingName])
- points = points + partialPoints
- exit repeat
- end if
- end repeat
- else
- reportDrink("Abysmal" && textName & ". No points for" && ingredient)
- end if
- else
- reportDrink("Scored full points" && ingInfo[#p] && "for correct" && textName)
- points = points + ingInfo[#p]
- end if
- return points
- end
-
- on mEvaluateIfPrimaryOrSubstituteAvoidDupes me, matchRecipe, ingredient, textName, points, myContents, correctQuantity
- global gIngredients
- ingInfo = findIngredientInRecipe(matchRecipe, ingredient)
- if voidp(ingInfo) then
- reportDrink("Lost 2 points for wrong action" && ingredient)
- else
- reportDrink("Scored points" && ingInfo[#p] && "for correct" && textName)
- points = points + ingInfo[#p]
- end if
- return points
- end
-
- on secondsWaitingForDrink me
- return ticksToSeconds(pTimeServed - pTimeOrdered)
- end
-
- on tip me
- pPatronGaveTip = 1
- pay = getDollarScore(secondsWaitingForDrink(me), pAccuracy, currentPatience(me), pDifficulty)
- cents = pay - integer(pay / 100.0 * 100)
- tens = floor(cents * 10)
- pennies = integer(cents * 100) mod 10
- if (pennies <> 0) and (pennies <> 5) then
- cents = (tens * 10) + getAt([0, 5], random(2))
- pay = floor(pay) + (float(cents) / 100.0)
- end if
- pay = pay + (min(1, me.pDrinkTicket) * currentLevel(#TIXINFCOST))
- regTip(pay)
- end
-
- on sipDrink me
- if getBarTopGlass(gBarTopManager, pMyBarSlot) <> #none then
- sendSprite(barSlotToGlassSprite(gBarTopManager, pMyBarSlot), #mReduceLiquid)
- playAnim(me, #drink, VOID, #doneDrinking)
- end if
- end
-
- on passOut me
- playAnim(me, #passOut)
- end
-
- on getPropertyDescriptionList me
- characterList = [#AT, #BC, #CG, #EM, #GR, #JF, #JS, #KY, #LC, #LG, #LM, #LN, #OG, #RN, #SC, #SM, #TF, #TJ, #VH, #XF]
- return [#pCharCode: [#default: #OG, #comment: "Character Code", #range: characterList, #format: #symbol]]
- end
-
- on drinkTicket me, inSound
- global gPlayerDrinkTickets, gPlayerTips
- if bouncingOrRetreating(me) then
- alertBeep()
- exit
- end if
- if voidp(inSound) then
- inSound = "ticket_sound"
- end if
- maxTickets = sumGameLevels(#TIX)
- costPerTicket = currentLevel(#TIXCOST)
- nextTicket = gPlayerDrinkTickets + 1
- playIt = 0
- if nextTicket > maxTickets then
- if gPlayerTips >= costPerTicket then
- regTip(-costPerTicket, 1)
- playIt = 1
- else
- soundFX2("bad_drink", 0, 0)
- end if
- else
- if nextTicket = maxTickets then
- ticketWarning = #lastOne
- playIt = 1
- else
- if nextTicket = (maxTickets - 1) then
- ticketWarning = #freebies
- end if
- playIt = 1
- end if
- end if
- if playIt then
- if busy(me) then
- if statusIs(me, [#greeting, #greeted, #carded, #ordered, #served]) then
- goBase(me)
- else
- pleaseWait()
- exit
- end if
- end if
- me.pDrinkTicket = me.pDrinkTicket + 1
- gPlayerDrinkTickets = gPlayerDrinkTickets + 1
- soundFX(inSound, 0, 1)
- case ticketWarning of
- #lastOne:
- managerVO("N03")
- #freebies:
- managerVO("N02")
- end case
- goBase(me)
- playAnim(me, #TICKET)
- end if
- end
-
- on card me, inSound
- global gGaveIDcardHint
- if label("card") = marker(0) then
- returnToBar()
- exit
- end if
- if bouncingOrRetreating(me) then
- alertBeep()
- exit
- end if
- if voidp(inSound) then
- inSound = "card_sound"
- end if
- if me.pAlreadyCarded and statusIs(me, [#carded, #ordered, #ordering, #served, #serving]) then
- managerVO("E07")
- end if
- case pStatus of
- #approaching, #greeting, #greeted, #acknowledged, #carded, #ordering, #ordered, #served, #serving:
- replaceDraggingAnything()
- soundFX(inSound, 0, 0)
- gGaveIDcardHint = 1
- waitCursor()
- dismissToolTip(1)
- go("Card")
- if not me.pAlreadyCarded or statusIs(me, [#approaching, #greeting, #greeted, #acknowledged]) then
- me.pAlreadyCarded = 1
- pStatus = #carded
- end if
- #retreating, #bouncing:
- alertBeep()
- exit
- end case
- end
-
- on othersBusy me, statuses
- global gCharacterSprites
- numBusy = 0
- repeat with X in gCharacterSprites
- if X = me.spriteNum then
- next repeat
- end if
- if sendSprite(X, #busy) then
- if voidp(statuses) then
- numBusy = numBusy + 1
- next repeat
- end if
- if sendSprite(X, #statusIs, statuses) then
- numBusy = numBusy + 1
- end if
- end if
- end repeat
- return numBusy
- end
-